According to The Quote Investigator, Einstein probably never said this, although there is some evidence to suggest that he did. The earliest known reference to the quote is in a book written in 1942 by the German-American psychiatrist Fritz Perls, where it's attributed to "a great astronomer". It also doesn't include the words "and I'm not sure about the former".
It is odd, says the Quote Investigator, to describe Einstein as an astronomer. Perls, it says, returns to the quote several times in later books, with bits added and bits left out. In 1969 Perls published In and Out the Garbage Pail which is labeled a "novel autobiography"; in this he writes, 'I spent one afternoon with Albert Einstein ... I still love to quote a statement of his: "Two things are infinite, the universe and human stupidity, and I am not yet completely sure about the universe."'
An answer on Quora.com is less polite: "Einstein NEVER said that. Nor would he have ever said such a thing." The answer refers to The Quotable Einstein, by Alice Caparice (a biographer of Einstein), and summarises: "Caparice lists this quote as 'Probably not by Einstein', and says the quote is similar to something said by Flaubert in an 1880 letter to Guy de Maupassant. (Paul Mainwood wisely notes that Fritz Perls is a notoriously unreliable source, and did not understand even the basics of Einstein's ideas.)"
Wikiquote (search for "perls") is also extremely sceptical.
© Haydn Thompson 2020